/**
 * Created by 白雨浓 on 2018/1/16 12:32.
 */

import {types} from './types';

export default{

    bean(self, table, fields){
        let haveDate = false;

        let attr = '';
        for (const field of fields) {
            const fn = field.COLUMN_NAME;
            if (fn === 'id' || fn === 'state' || fn === 'create_time' || fn === 'update_time') {
                continue;
            }
            if (types[field.DATA_TYPE] === 'Date') {
                haveDate = true;
            }
            attr += `\tprivate ${types[field.DATA_TYPE]} ${self.$str.toCamel(field.COLUMN_NAME)};\n`;
        }

        let clsName = self.$str.toCamel(table);
        clsName = clsName.substring(0, 1).toUpperCase() + clsName.substring(1);

        return `package ${self.config.packageName}.bean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
${haveDate ? 'import java.util.Date;' : ''}

/**
 * ${self.config.packageName}.bean
 *
 * @author 白雨浓
 * date: ${self.$date.format(new Date(), 'yyyy/MM/dd hh:mm')}
 * content: 模型
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ${clsName}Bean implements Serializable {

    ${attr}
}
        `;
    }
    ,
}